package com.lh.learning.mq.controller;

import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author luohuan
 * @date 2020/6/18
 **/
@RestController
@RequestMapping("/rabbitmq")
public class RabbitMqController {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @PostMapping("/send")
    public void sendMsg(@RequestBody String msg) {
        rabbitTemplate.convertAndSend("direct.message", "message.routing", msg);
    }
}
